package entity;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MatchedLogRec {
	private String logName;//用户登录名
	private String logIP;//用户登录时所在终端机器的IP地址
	private long loginTime;//用户登入时刻(毫秒)，原日志中数据单位是秒
	private long logoutTime;//用户登出时刻(毫秒)，	原日志中数据单位是秒
	private long durations;//用户在线时间长度(毫秒)
	private String labIP;//用户登录的实验室IP地址
	
	public MatchedLogRec() {
	}
	
	public MatchedLogRec(String logName, String logIP, long loginTime, long logoutTime, long durations, String labIP) {
		this.logName = logName;
		this.logIP = logIP;
		this.loginTime = loginTime;
		this.logoutTime = logoutTime;
		this.durations = durations;
		this.labIP = labIP;
	}

	public long getDurations() {
		return durations;
	}
	public void setDurations(long durations) {
		this.durations = durations;
	}
	public String getLabIP() {
		return labIP;
	}
	public void setLabIP(String labIP) {
		this.labIP = labIP;
	}
	public long getLoginTime() {
		return loginTime;
	}
	public void setLoginTime(long loginTime) {
		this.loginTime = loginTime;
	}
	public String getLogIP() {
		return logIP;
	}
	public void setLogIP(String logIP) {
		this.logIP = logIP;
	}
	public String getLogName() {
		return logName;
	}
	public void setLogName(String logName) {
		this.logName = logName;
	}
	public long getLogoutTime() {
		return logoutTime;
	}
	public void setLogoutTime(long logoutTime) {
		this.logoutTime = logoutTime;
	}

	//DataWriter使用
	@Override
	public String toString() {
		Date login,logout;
		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		login= new Date(loginTime);
		logout= new Date(logoutTime);
		long duration = durations/1000;
		String s=logName+"\t"+sdf.format(login)+"\t"+sdf.format(logout)+"\t"+duration+"\t"+logIP;
		return s;
	}
	
	//DataSender使用
	public String tostring(){
		String s=logName+","+labIP+","+loginTime+","+logoutTime+","+durations+","+logIP;
		return s;
	}

}
